package com.hui.util;

import lombok.Data;

/**
 *
 */
@Data
public class BaseParameters {
    /*分页起始记录数*/
    private Integer start;
    /*当前页码*/
    private Integer page;
    /*每页显示的记录数*/
    private Integer rows;
    /*排序字段*/
    private String orderBy;

    /**
     * @Description: TODO(设置排序)
     */
    public BaseParameters setOrderBy(String columnName, OrderByDirection dir) {
        StringBuilder sort = new StringBuilder();
        if (orderBy != null && !(orderBy.trim().equals(""))) {
            sort.append(this.orderBy);
            sort.append(",");
        } else {
            sort.append("order by ");
        }
        sort.append(columnName);
        sort.append(" ");
        sort.append(dir.toString());
        sort.append(" ");
        this.orderBy = sort.toString();
        return this;
    }
}

